﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for GioHangBUS
/// </summary>
public class GioHangBUS
{
	private GioHangDAO objGioHangDAO;
    public GioHangBUS(string strPath)
    {
        objGioHangDAO = new GioHangDAO(strPath);
    }
    public DataSet GetItemsIntoGioHang(string cartID)
    {
        DataSet ds;
        try
        {
            ds = objGioHangDAO.GetItemsIntoGioHang(cartID);
            return ds;
        }
        catch (System.Exception e)
        {
            throw new Exception(e.Message, e.InnerException);
        }
    }
    public DataSet GetTotalAmountGioHang(string CartID)
    {
        try
        {
            DataSet ds;
            ds = objGioHangDAO.GetTotalAmountGioHang(CartID);
            return ds;
        }
        catch (System.Exception e)
        {
            throw new Exception(e.Message, e.InnerException);
        }
    }

    public Boolean AddItemToGioHang(GioHangDTO shoppingCart)
    {
        try
        {
            return objGioHangDAO.AddItemToGioHang(shoppingCart);
        }
        catch (System.Exception e)
        {
            throw new System.Exception(e.Message,
                     e.InnerException);
        }
    }

    public Boolean RemoveItemInGioHang(string CartID, int ProductID)
    {
        try
        {
            return this.objGioHangDAO.RemoveItemInGioHang(CartID, ProductID);
        }
        catch (System.Exception e)
        {
            throw new System.Exception(e.Message,
                   e.InnerException);
        }
    }

    public Boolean UpdateItemInGioHang(GioHangDTO shoppingCart)
    {
        try
        {
            return objGioHangDAO.UpdateItemInGioHang(shoppingCart);
        }
        catch (System.Exception e)
        {
            throw new Exception(e.Message, e.InnerException);
        }
    }

    public DataSet CountOldCartsInGioHang(int days)
    {
        try
        {
            DataSet ds;
            ds = objGioHangDAO.CountOldCartsInGioHang(days);
            return ds;
        }
        catch (System.Exception e)
        {
            throw new Exception(e.Message, e.InnerException);
        }
    }

    public Boolean DeleteOldCartsFromGioHang(int days)
    {
        try
        {
            return this.objGioHangDAO.DeleteOldCartsFromGioHang(days);
        }
        catch (System.Exception e)
        {
            throw new System.Exception(e.Message,
                   e.InnerException);
        }
    }
}
